﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using CubicFWNet.Data.Models;
using CubicFWNet.Data.ViewModal;

namespace CubicFWNet.Data.SystemManager
{
    public class PurchasePrintSubRepository : RepositoryBase<PurchasePrintSub>
    {
        public IQueryable<NewProductView> GetListPurchasePrintSub(Guid id)
        {
            var result = from pps in dbcontext.PurchasePrintSubs
                         join pro in dbcontext.Products
                         on pps.ProductId equals pro.Id
                         where pps.PurchasePrintId == id
                         select new NewProductView
                        {
                            ProductId = pro.Id,
                            ProductName = pro.Name,
                            ProductUnit = pro.Unit,
                            ProductFormat = pro.Format,
                            ProductSizeWidth = pro.SizeWidth,
                            ProductSizeLenth = pro.SizeLenth,
                            ProductPrice = pro.Price,
                            ProductAmount = pps.Amount,
                            TotalMoney = pps.CostPrice * pps.Amount,
                            CostPrice = pps.CostPrice,
                            Memo = pps.Memo
                        };
            return result;
        }

    }
}
